//
//  NoDataView.swift
//  E-CycleForShop
//
//  Created by enghou on 17/3/29.
//  Copyright © 2017年 xyxorigation. All rights reserved.
//

import UIKit

class NoDataView: BaseView {

    //需要添加点击刷新
    //需要添加提示
    
    var refreshBlock : ()->Void = {
        
    }
    
    let activeIndicator = UIActivityIndicatorView.init(activityIndicatorStyle: .white)
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = UIColor.white
        let label = UILabel.init()
        label.font = UIFont.systemFont(ofSize: 26 * YXWidthScale)
        label.text = "暂无数据，您可以点击屏幕刷新"
        label.textColor = UIColor.colorWithHexString(hex: "2c2c2c")
        let size = label.text!.StringSize(font: label.font)
        label.frame = CGRect.init(x: frame.size.width / 2 - size.width / 2, y: 50 * YXHeightScale, width: size.width, height: size.height)
        self.addSubview(label)
        activeIndicator.center = self.center
        activeIndicator.color = UIColor.lightGray
        activeIndicator.stopAnimating()
        self.addSubview(activeIndicator)
    }
    
    func endRefresh() -> Void {
        activeIndicator.stopAnimating()
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        //beginload
        activeIndicator.startAnimating()
        refreshBlock()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */

}
